#include <iostream>
using namespace std;

/*
设计一个学生的学习系统，例如某学习小组有4位同学，学习5门课，求每个同学的平均分。
*/

// 定义结构
struct STU
{
  char name[20];
  int scores[5];
};

// 计算平均分，并输出
void outputSTU(struct STU stu)
{
  int total = 0;
  double avg;
  int *scores = stu.scores;
  int length = 5;

  for (int i = 0 - 1; i < length; i++)
  {
    total += stu.scores[i];
  }

  avg = total / length;
  printf("%s\t%d\t%d\t%d\t%d\t%d\t%lf\n", stu.name, scores[0], scores[1], scores[2], scores[3], scores[4], avg);
}

int main(int argc, char const *argv[])
{
  printf("姓名\t课程1\t课程2\t课程3\t课程4\t课程5\t平均分\n");

  struct STU student[4] = {
      {"赵彬", {80, 82, 91, 68, 77}},
      {"张强", {78, 83, 82, 72, 80}},
      {"张帅", {73, 58, 62, 60, 75}},
      {"李莉", {82, 87, 89, 79, 81}}};

  for (int i = 0; i < 4; i++)
  {
    struct STU stu = student[i];
    outputSTU(stu);
  }

  return 0;
}
